﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsGame4
{
    class Projectile :  Object
    {
        private int distance;
        private String idEmissor;
        private String idVictim;
        public Projectile(String id, Position2D position, Model model) : base(id, position, model)
        {
            type = Object.TypeObject.projectile;
            this.speed = 20;
            //speed = 1;
            this.distance = 2000;
            this.idEmissor = "";
        }

        public String IdEmissor
        {
            get { return idEmissor; }
            set { idEmissor = value; }
        }

        public String IdVictim
        {
            get { return idVictim; }
            set { idVictim = value; }
        }

        public int Distance
        {
            get { return distance; }
            set { distance = value; }
        }

        public void move()
        {
            if (movement != null)
            {
                int dx = position.X - movement.X;
                int dy = position.Y - movement.Y;

                if (dx == 0 && dy == 0)
                {
                    movement = null;

                }
                else
                {
                    if (dx != 0)
                        position.X -= speed * Math.Sign(dx);
                    else
                    {
                        if (dy != 0)
                            position.Y -= speed * Math.Sign(dy);
                    }
                }
            }
        }
    }
}
